Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory: Make regex patterns raw #971

Merged
merged 3 commits into from
Oct 10, 2024
Merged

memory: Make regex patterns raw #971

merged 3 commits into from
Oct 10, 2024

Conversation

mrmacete
Copy link
Contributor

@mrmacete mrmacete commented Oct 8, 2024

According to the docs of g_regex_new about the G_REGEX_RAW flag: "Usually strings must be valid UTF-8 strings, using this flag they are considered as a raw sequence of bytes."

The "strings" this refers to are the haystacks we then pass to g_regex_match_full when searching.

Without the flag, memory search with regex patterns can get interrupted before the range is over, when "invalid" bytes are encountered, resulting in false negatives.

According to the docs of `g_regex_new`: "Usually strings must be valid
UTF-8 strings, using this flag they are considered as a raw sequence
of bytes."

The "strings" this refers to are the haystacks we then pass to
`g_regex_match_full` when searching.

Without the flag, memory search with regex patterns can get
interrupted before the range is over, when "invalid" bytes are
encountered, resulting in false negatives.
@mrmacete mrmacete requested a review from oleavr October 8, 2024 15:16
@mrmacete mrmacete marked this pull request as draft October 10, 2024 07:46
@mrmacete mrmacete marked this pull request as ready for review October 10, 2024 07:51
@oleavr oleavr merged commit e4c1125 into main Oct 10, 2024
29 of 32 checks passed
@oleavr oleavr deleted the fix/regex-pattern-raw branch October 10, 2024 18:06
@oleavr
Copy link
Member

oleavr commented Oct 10, 2024

Thanks! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants